package com.ruoyi.business.controller;

import cn.dev33.satoken.annotation.SaCheckPermission;
import com.ruoyi.business.domain.dto.admin.koc.TbUserKocProductLogPageDTO;
import com.ruoyi.business.domain.vo.TbUserKocProductLogPageVO;
import com.ruoyi.business.domain.vo.TraceabilityDetailVO;
import com.ruoyi.business.service.koc.ITbUserKocProductLogService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.PageQuery;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.page.TableDataInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.validation.constraints.NotNull;

/**
 * koc用户产品获取流水
 *
 * @author chenran
 */
@Validated
@Api(value = "koc用户产品获取流水", tags = {"koc用户产品获取流水"})
@RequiredArgsConstructor
@RestController
@RequestMapping("/business/user/koc/product/log")
public class TbUserKocProductLogController extends BaseController {

    @Resource
    private ITbUserKocProductLogService tbUserKocProductLogService;

    @ApiOperation("koc用户产品获取流水")
    @SaCheckPermission("business:koc:product:log:page")
    @GetMapping("/list")
    public TableDataInfo<TbUserKocProductLogPageVO> list(TbUserKocProductLogPageDTO tbUserKocProductLogPageDTO, PageQuery pageQuery) {
        return tbUserKocProductLogService.selectPageList(tbUserKocProductLogPageDTO, pageQuery);
    }

    @ApiOperation("根据sourceId溯源审核详情")
    @SaCheckPermission("business:koc:product:log:detail")
    @GetMapping("/{sourceId}")
    public R<TraceabilityDetailVO> getInfo(@ApiParam("来源id")
                                           @NotNull(message = "来源id不能为空")
                                           @PathVariable("sourceId") Long sourceId) {
        return R.ok(tbUserKocProductLogService.selectDetail(sourceId));
    }

}
